<%--
  Created by IntelliJ IDEA.
  User: 29513
  Date: 2021/11/3
  Time: 10:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    //获取项目的根路径
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <meta charset="utf-8">
    <title>放射科</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <%--导入layui的css样式--%>
    <link rel="stylesheet" href="<%=basePath%>static/layui-v2.6.5/layui/css/layui.css" media="all">
    <script type="text/javascript" src="<%=basePath%>static/layui-v2.6.5/layui/layui.js"></script>
    <link rel="stylesheet" href="<%=basePath%>static/dept/css/chaCt.css">
    <script type="text/javascript" src="<%=basePath%>static/jquery/jquery-1.12.4.js"></script>
    <link rel="stylesheet" href="<%=basePath%>/static/swee/sweetalert.css">
    <script src="<%=basePath%>/static/swee/sweetalert-dev.js"></script>
</head>
<body>
<div class="chaCt-body">
    <div class="chaCt-host"><%--主页--%>
        <div class="chaCt-search"><%--搜索框条件--%>
            <form class="layui-form" action="${pageContext.request.contextPath}/dept/radiology" method="post">
                诊断号:<input type="text" name="id" value="${id}">
                用户姓名:<input type="text" name="userName" value="${userName}">
                需检查类型:
                <div class="layui-input-inline" style="width:180px">
                <select name="userType" id="selType">
                    <option value="${userType}">${userType}</option>
                    <option value="">全部</option>
                    <option value="CT">CT</option>
                    <option value="核磁共振" >核磁共振</option>
                    <option value="B超">B超</option>
                    <option value="彩超">彩超</option>
                </select>
                </div>
                <button type="submit" class="layui-btn" lay-filter="demo1">查询</button>
            </form>
        </div>
        <%--显示数据--%>
        <div class="chaCt-centre">
            <table class="layui-table" lay-even lay-skin="row" lay-size="lg">
                <thead>
                <tr class="centre-tr">
                    <td>诊断号</td>
                    <td>用户姓名</td>
                    <td>检查时间</td>
                    <td>检查类型</td>
                    <td>检查部位</td>
                    <td>操作</td>
                    <td>近期诊断记录</td>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${pageOne.list}" var="list">
                    <tr>
                        <td>${list.id}</td>
                        <td>${list.userName}</td>
                        <td>${list.userTime}</td>
                        <td>${list.userType}</td>
                        <td>${list.usercheck}</td>
                        <td>
                            <button  class="layui-btn layui-btn-normal layui-btn-radius"
                                 style="background-color:#009f95" onclick="zd('${list.id}','${list.userName}','${list.userType}','${sessionScope.doctor.doctorId}','${list.userTime}','${list.usercheck}')"
                            >
                                诊断
                            </button>
                        </td>
                        <td>
                            <button  class="layui-btn layui-btn-normal layui-btn-radius"
                                    onclick="lszd(${list.id})" style="background-color:#009f95">
                                历史诊断记录
                            </button>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
            <div class="chaCt-base"><%--页面上下页--%>
                <%--设置首页--%>
                <a href="${pageContext.request.contextPath}/dept/radiology?pageNum=${pageOne.firstPage}&id=${id}&userName=${userName}&userType=${userType}">首页</a>
                <a href="${pageContext.request.contextPath}/dept/radiology?pageNum=${pageOne.prePage}&id=${id}&userName=${userName}&userType=${userType}">上一页</a>
                ${pageOne.pageNum}/${pageOne.pages}
                <a href="${pageContext.request.contextPath}/dept/radiology?pageNum=${pageOne.nextPage}&id=${id}&userName=${userName}&userType=${userType}">下一页</a>
                <%--设置尾页--%>
                <a href="${pageContext.request.contextPath}/dept/radiology?pageNum=${pageOne.lastPage}&id=${id}&userName=${userName}&userType=${userType}">尾页</a>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var imgUrl;
    function zd(a,b,c,d,e,f){
        var cdiagnoseNO=a;
        var cuserName=b;
        var checkType=c;
        var doctorId=d;
        var userTime=e;
        var inspectionItem=f;
        if (inspectionItem=='头部'){
            imgUrl='https://ss1.baidu.com/-4o3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/3812b31bb051f819a281d363d8b44aed2e73e777.jpg';
        }else if (inspectionItem=='颈部'){
            imgUrl='https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fbbs.radida.com%2Fbbs%2Fupload%2Fforum%2F2007%2F04%2F292339023912.jpg&refer=http%3A%2F%2Fbbs.radida.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1639729884&t=bf6433fad7600952a094f418189acdbd';
        }else if (inspectionItem=='胸部'){
            imgUrl='https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fiiyi2.120askimages.com%2Fforum%2F2011%2F06%2F27%2F1106271828ba84489f6b7f7b89.jpg&refer=http%3A%2F%2Fiiyi2.120askimages.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1639730062&t=94df0e440d3645967d49b5cd38590ee4';
        }else if (inspectionItem=='背部'){
            imgUrl='https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg1.cache.netease.com%2Fcatchpic%2F9%2F94%2F947C8375063B189CDDFED5BA858ACAE1.jpg&refer=http%3A%2F%2Fimg1.cache.netease.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1639730136&t=0fc58da185cea96360b7cda795bad7f5';
        }else if (inspectionItem=='脊椎'){
            imgUrl='https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fn3.hdfimg.com%2Fg9%2FM01%2F2C%2FEC%2FuoYBAFfETOaAa6ITAAInK0XKvkI515.jpg%3F_ms_%3D757f&refer=http%3A%2F%2Fn3.hdfimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1639730196&t=943f000cf87cc90912181c555355bae4';
        }else if (inspectionItem=='肩部'){
            imgUrl='https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg1.dxycdn.com%2F2019%2F0919%2F080%2F3369116960725355184-8w.jpg%21q70&refer=http%3A%2F%2Fimg1.dxycdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1639730296&t=ac2ad10a63200aa4b366e57c3648e49d';
        }else if (inspectionItem=='上臂'){
            imgUrl='https://img0.baidu.com/it/u=684147827,3814686042&fm=26&fmt=auto';
        }else if (inspectionItem=='前臂'){
            imgUrl='https://img0.baidu.com/it/u=2422447581,3478399066&fm=26&fmt=auto';
        }else if (inspectionItem=='手'){
            imgUrl='https://img1.baidu.com/it/u=3380849289,3583623179&fm=26&fmt=auto';
        }else if (inspectionItem=='臀部'){
            imgUrl='https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fbbs.radida.com%2Fbbs%2Fdata%2Fattachment%2Fforum%2Fpw%2FMon_1410%2F4_3912_ea1c8ff3609ef1f.jpg&refer=http%3A%2F%2Fbbs.radida.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1639730730&t=4aee23d638027a81b267c1d47aff64c4';
        }else if (inspectionItem=='大腿'){
            imgUrl='https://img1.baidu.com/it/u=409428533,3080374306&fm=26&fmt=auto';
        }else if (inspectionItem=='小腿'){
            imgUrl='https://img1.baidu.com/it/u=1599214749,365909115&fm=26&fmt=auto';
        }else if (inspectionItem=='足'){
            imgUrl='https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg04.allinmd.cn%2Fcase%2F2015%2F03%2F05%2F1425538830176_1425539123034.jpg&refer=http%3A%2F%2Fimg04.allinmd.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1639730857&t=a9f2b051b7d99e3bfa82b639d997ec8a';
        }
        swal({
            customClass: "sweetAlertTop",
            title: "<small>请填写诊断结果</small>",
            text:
                "<img id='checkImg' src='x' onerror='getUrl()' width='40%' height='35%'>"
                +"<p>诊断结果</p><input type='text' name='diagnose' id='jg'>"
            ,
            html: true,
            type: "prompt",
            showConfirmButton: true,
            confirmButtonText: "确定",
            showCancelButton: true,
            cancelButtonText: "取消"
        }, function(isConfirm){
            if (isConfirm){
                var jg = document.getElementById('jg').value;  //检查结果
                $.ajax({
                    url: "http://localhost:8080/dept/insertCT",
                    type: "post",
                    data: {
                        cdiagnoseNO: cdiagnoseNO,
                        cuserName: cuserName,
                        checkType: checkType,
                        inspectionItem: inspectionItem,
                        diagnose: jg,
                        doctorid: doctorId,
                        userTime: userTime
                    },
                    dataType: "json",
                    success: function (data) {
                        if (data==true){
                            swal({
                                title: "诊断完成!",
                                type: "warning",
                                confirmButtonText: "确定！"
                            },function (){
                                location.reload()
                            })
                        }else {
                            swal("诊断失败!!!")
                        }
                    }
                })
            }
        })
    }
    function lszd(cdiagnoseNO){
        $.ajax({
            url: "http://localhost:8080/dept/lszd",
            type: "post",
            data: {
                cdiagnoseNO: cdiagnoseNO
            },
            dataType: "json",
            success: function (data) {
                let zdstr=`<table class='layui-table'>
                            <thead>
                                <tr>
                                    <th>记录</th>
                                    <th>诊断时间</th>
                                    <th>检查类型</th>
                                    <th>检查部位</th>
                                    <th>检查结果</th>
                                    <th>医生</th>
                                </tr>
                            </thead>`;
                $.each(data,function (index,val) {
                    zdstr+="<tbody><tr><td>"+(index+1)+"</td>"
                    zdstr+="<td>"+val.ctime+"</td>"
                    zdstr+="<td>"+val.checkType+"</td>"
                    zdstr+="<td>"+val.inspectionItem+"</td>"
                    zdstr+="<td>"+val.diagnose+"</td>"
                    zdstr+="<td>"+val.doctorName+"</td></tr></tbody>"
                })
                zdstr+="</table>";
                swal({
                    customClass: "sweetAlertTop sweetAlertBigWidth",
                    title: "<small>近期诊断</small>",
                    text: zdstr,
                    html: true,
                    type: "prompt",
                    confirmButtonText: "确定！"
                })
            }
        })
    }
    function getUrl(){
        document.getElementById('checkImg').src=imgUrl
    }
</script>
</body>
</html>
